/* arrow_symbol.h */

#ifndef DODO_ARROW_SYMBOL_H
#define DODO_ARROW_SYMBOL_H

#include <dodo_plot/symbol/symbol_base.h>
#include <dodo_plot/kernel/plotter.h>

namespace dodo_plot
{

class Arrow_Symbol : public Symbol_Base
{
public:
	Arrow_Symbol(
		double degrees = 0, 
		double size = 20,
		double cap_size = 5,
		double line_width = 1,
		const Color& line_color = color_name::BLACK)
		: Symbol_Base(size, line_width, line_color, color_name::TRANSPARENT),
		degrees_(degrees)
	{ 
		cap_size_ = (size < 2 * cap_size) ?
			0.5 * size : cap_size;
	}

	void draw(const Plotter& plotter) const
	{
		Point start = plotter.get_abs_point(0, 0);

		plotter.save();
		plotter.begin_new_path();
		plotter.set_color(line_color_);
		plotter.set_line_width(line_width_);
		plotter.abs_move_to(start);
		plotter.rotate_degrees(degrees_);
		plotter.abs_rel_line_to(0, -size_);
		Point end = plotter.get_current_point();
		plotter.abs_rel_line_to(0.6 * cap_size_, cap_size_);
		plotter.abs_move_to(end);
		plotter.abs_rel_line_to(-0.6 * cap_size_, cap_size_);
		plotter.stroke();
		plotter.restore();
	}

private:
	double degrees_;
	double cap_size_;
};

}

#endif //DODO_ARROW_SYMBOL_H

